/*
 * from : http://zhedahht.blog.163.com/blog/static/254111742007499363479/
 */
#include <stdio.h>
#include <algorithm>

void permutation( char *str, char *begin )
{
	if( '\0' == *begin ) {
		printf( "%s\n", str );
		return;
	}
	char *p = begin;
	while( '\0' != *p ) {
		if( p != begin )
			std::swap( *begin, *p );
		permutation( str, begin + 1 );
		if( p != begin )
			std::swap( *begin, *p );
		++p;
	}
}

void permutation( char *str )
{
	if( NULL == str )
		return;
	permutation( str, str );
}

int main( int argc, char *argv[] )
{
	permutation( argv[1] );
}

